package com.example.apidemo2;

import com.example.apidemo2.R;
import com.pos.api.FingerPrint;
import com.pos.api.FingerPrint.FingerPrintConnectStatusListener;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener{
	
	private Button btnSys;
	private Button btnMcr;
	private Button btnIcc;
	private Button btnPicc;
	private Button btnNationalSecret;
	private Button btnFingerPrint;
	private Button btnIDcard;
	private Button btnMoneyBox;
	
	private FingerPrint fingerPrint;
	public static Context mContext;
	private Button btnPci;
	private Button btnExit;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		initView();
		mContext = getApplicationContext();
	}

	private void initView() {
		// TODO Auto-generated method stub
		btnSys = (Button) findViewById(R.id.btnSystem);
		btnMcr = (Button) findViewById(R.id.btnMcr);
		btnIcc = (Button) findViewById(R.id.btnIcc);
		btnPicc = (Button) findViewById(R.id.btnPicc);
		btnNationalSecret = (Button) findViewById(R.id.btnNationalSecret);
		btnFingerPrint = (Button) findViewById(R.id.btnFingerPrint);
		btnIDcard = (Button) findViewById(R.id.btnIDcard);
		btnPci = (Button) findViewById(R.id.btnPci);
		btnExit = (Button) findViewById(R.id.btnExit);
		btnMoneyBox = (Button) findViewById(R.id.btnMoneyBox);
		
		btnExit.setOnClickListener(this);
		btnPci.setOnClickListener(this);
		btnFingerPrint.setOnClickListener(this);
		btnIDcard.setOnClickListener(this);
		btnPicc.setOnClickListener(this);
		btnIcc.setOnClickListener(this);
		btnNationalSecret.setOnClickListener(this);
		btnMcr.setOnClickListener(this);
		btnSys.setOnClickListener(this);
		btnMoneyBox.setOnClickListener(this);
		findViewById(R.id.serialPortSetBtn).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(MainActivity.this,SerialPortPreferences.class));
			}
		});
	
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		Log.i("unifou", "btnPci=="+v.getId());
		Intent intent = null;
		switch (v.getId()) {
			case R.id.btnSystem:
				
				intent = new Intent(this,SysActivity.class);
				break;
			case R.id.btnMcr:
				
				intent = new Intent(this,McrActivity.class);
				break;
			case R.id.btnIcc:
				intent = new Intent(this,IccActivity.class);
				break;
			case R.id.btnPicc:
				intent = new Intent(this,PiccActivity.class);
				break;
				
			case R.id.btnNationalSecret:
				intent = new Intent(this,NationalSecretActivity.class);
				break;
			case R.id.btnIDcard:
				intent = new Intent(this,IDCardActivity.class);
				break;
	
			case R.id.btnFingerPrint:
			
				intent = new Intent(this,SerialPortActivity.class);
				
				break;
			case R.id.btnPci:
		
				intent = new Intent(this,PciActivity.class);
				break;
			case R.id.btnExit:
				finish();
				break;
			case R.id.btnMoneyBox:
				intent = new Intent(this,MoneyBoxActivity.class);
				break;
			default:
				break;
				
				
		}
		if(intent != null){
			startActivity(intent);
		}


	}

}
